package com.example.hello.views.access_control;

import com.example.hello.HelloUI;
import com.example.hello.POJO.UserPOJO;
import com.example.hello.views.Wireframe1;
import com.vaadin.navigator.View;
import com.vaadin.navigator.ViewChangeListener;
import com.vaadin.ui.VerticalLayout;

public class LogOut extends VerticalLayout implements View {

    public static final String NAME = "logout";

    @Override
    public void enter(ViewChangeListener.ViewChangeEvent event) {
        ((HelloUI) HelloUI.getCurrent()).setUser(new UserPOJO());
        getUI().getSession().setAttribute("isLoggedIn", false);
        ((HelloUI) HelloUI.getCurrent()).setLogInOutFlag(true);
        getUI().getNavigator().navigateTo(Wireframe1.NAME);
    }

}